import Home from '@/views/home'
import Category from '@/views/category'
import SubCategory from '@/views/category/SubCategory'
import List from '@/views/list'
import Detail from '@/views/detail'
import Cart from '@/views/cart'
import Mine from '@/views/mine'
import Login from '@/views/login'
import Register from '@/views/register'
import Tabbar from '@/components/Tabbar'
import SearchHeader from '@/components/SearchHeader'
import TitleHeader from '@/components/TitleHeader'
const routes = [
  {
    path: '/',
    redirect: '/home',
    meta: {}
  },
  {
    path: '/home',
    name: 'home',
    components: {
      header: SearchHeader,
      default: Home,
      footer: Tabbar
    },
    meta: {
      isNav: true, // 表示是否放置到tabber的导航中
      title: '首页',
      icon: '&#xe613;'
    }
  },
  {
    path: '/category',
    name: 'category',
    components: {
      header: TitleHeader,
      default: Category,
      footer: Tabbar
    },
    children: [ // 嵌套子路由
      {
        path: 'sub/:id',
        component: SubCategory,
        meta: {
          title: '二级分类'
        }
      }
    ],
    meta: {
      isNav: true,
      title: '分类',
      icon: '&#xe618;'
    }
  },
  {
    path: '/list',
    name: 'list',
    components: {
      header: TitleHeader,
      default: List
    },
    meta: {
      title: '商品列表'
    }
  },
  {
    path: '/detail/:id',
    name: 'detail',
    components: {
      header: TitleHeader,
      default: Detail
    },
    meta: {
      title: '商品详情'
    }
  },
  {
    path: '/cart',
    name: 'cart',
    components: {
      header: TitleHeader,
      default: Cart
    },
    meta: {
      isNav: true,
      title: '购物车',
      icon: '&#xe63d;'
    }
  },
  {
    path: '/mine',
    name: 'mine',
    components: {
      header: TitleHeader,
      default: Mine,
      footer: Tabbar
    },
    meta: {
      isNav: true,
      title: '我的',
      icon: '&#xe61c;'
    }
  },
  {
    path: '/login',
    name: 'login',
    components: {
      header: TitleHeader,
      default: Login
    },
    meta: {
      title: '登录'
    }
  },
  {
    path: '/register',
    name: 'register',
    component: Register,
    meta: {}
  }
]
export default routes
